<script type="text/javascript" SRC="/js/merchant/warehouseproducts.js"></script>
<script type="text/javascript" SRC="/js/merchant/ordersedit.js"></script>
<script>
var orderId=0;
<{if isset($order.order_id)}>
	orderId = "<{$order.order_id}>";
<{/if}>
$(function(){
	<{if isset($order.consignee_country_id)}>
		$("[name=consignee_country_id]").val("<{$order.consignee_country_id}>");
		getShipping();
		$("[name=shipping_method]").val("<{$order.shipping_method}>");
		getCost();
	<{/if}>
	<{if isset($order.products)}>
		<{foreach from=$order.products item=product}>
			html = '<div class="row height25 productRow<{$product.product_id}>">';
			html +='<div class="cell" style="width:18%;align-text:center"><input type="hidden" class="inputText product_sku"  name="product_sku[]" value="<{$product.product_sku}>" style="width:100px" readonly/> <{$product.product_sku}></div>';
			html +='<div class="cell" style="width:18%;align-text:center"><input type="hidden" class="inputText" name="op_description[]" value="<{$product.product_title}>" style="width:100px"/> <{$product.product_title}></div>';
			
			html +='<div class="cell" style="width:15%;align-text:center"><input type="hidden" class="inputText" name="op_description_cn[]" value="<{$product.product_title_cn}>" style="width:100px"/> <{$product.product_title_cn}></div>';
			
			html +='<div class="cell" style="width:18%;align-text:center"><{$product.category.poc_value}></div>';
			html +='<div class="cell" style="width:13%;align-text:center"><input type="text" class="inputText" name="op_quantity[]" value="<{$product.quantity}>" style="width:80px;text-align:right" id="op_quantity<{$product.product_id}>"  onblur="calWeihgt()"/></div>';
			html +='<div class="cell" style="width:10%;align-text:center" id="product_weight<{$product.product_id}>"><{$product.product_weight}></div>';
			html +='<div class="cell no-background" style="width:8%;align-text:center; padding-top:5px;"><img src="/images/icon_del.gif" name="button<{$product.product_sku}>" onclick="deleteProduct(this)" class="cursor" title="Delete"/><input type="hidden"  name="product_id[]" class ="product_id" value="<{$product.product_id}>"/><input type="hidden"  name="op_id[]" value="0" /></div>';
			html +='</div>';
			$('#ProductList').append(html);
			calWeihgt();
		<{/foreach}>
	<{/if}>

});
</script>
<style>
.middle{width:250px;}
.right{width:240px;}
</style>
<div class="position"><a href='/default/index'><{$languages['HOME']}></a> &gt; <a href='/merchant/my-account'><{$languages['MERCHANT_CENTER']}></a>  &gt; <{$languages['OPERATION']}> &gt; <{$languages['CREATE_ORDER']}></div>

<form id="editForm" name="editForm"  method="POST" >
<h4><{$languages['CREATE_ORDER']}></h4>
<div class="tab-div">
<div class="row height25" style="text-align:right;padding-right:10px">
<span class="button-2" onclick="OpenProductDiv()"><{$languages['SELECT_PRODUCT_LIST']}></span>
<span class="button-2" onclick="batchAddOrder()"><{$languages['UPLOAD_FILE']}></span>
</div>
<div class="row"  id="OrderProduct">
<div class="row height25 row-header">
<div class="cell sort" style="width:18%" >SKU</div>
<div class="cell sort" style="width:18%" ><{$languages['SKUNAME']}></div>
<div class="cell sort" style="width:15%" ><{$languages['CHINESENAME']}></div>
<div class="cell sort" style="width:18%" ><{$languages['CATEGORY']}></div>
<div class="cell sort" style="width:13%" ><{$languages['QUANTITY']}></div>
<div class="cell sort" style="width:10%" ><{$languages['WEIGHT']}>(Kg)</div>
<div class="cell no-background" style="width:8%"><{$languages['ACTIONS']}></div>
</div>

<div id="ProductList" >	</div>

<div class="height25">
	<div class="cell" style="width:51%;text-align:right" ><{$languages['TOTAL_WEIGHT']}>(Kg):&nbsp;&nbsp;</div>
	<div class="cell all_weight"  style="width:18%;text-align:right;" >0&nbsp;&nbsp;</div>
	<div class="cell" style="width:13%;text-align:right" ><{$languages['TOTAL_QUANTITY']}>:&nbsp;&nbsp;</div>
	<div class="cell parcel_quantity  no-background" style="width:18%;text-align:right;">0&nbsp;&nbsp;</div>
	<input type="hidden" name="parcel_quantity" class="parcel_quantity" value="" />
</div>

</div>
<div class="productError row height25" style="display:none"></div>
</div>

<h4><{$languages['ORDER_INFO']}></h4>
<div class="tab-div">
    <div class="row height28">
	<div class="left"  style="width:23%"><{$languages['ORDER_TYPE']}>：</div>
    <div class="middle">
    <{$languages['STANDARD']}>:<input type="radio" class="order_type" name="order_type" <{if isset($order.shipping_method)}><{if $order.shipping_method != 'SELFPICKUP'}>checked<{/if}><{else}>checked<{/if}> value="0"> &nbsp;&nbsp;<{$languages['SELFPICKUP']}>:<input type="radio" class="order_type"  name="order_type" <{if isset($order.shipping_method)}><{if $order.shipping_method == 'SELFPICKUP'}>checked<{/if}><{/if}> value="1">
    <span class="red">&nbsp;&nbsp;</span></div>
    <div class="right">&nbsp;</div>
	</div>

    <div class="row height28 ">
	<div class="left"  style="width:23%"><{$languages['REFERENCE_NO']}>：</div>
    <div class="middle">
    <input type="text" class="inputText remote" name="customer_order_code" value="<{if isset($order.customer_order_code)}><{$order.customer_order_code}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;</span></div>
    <div class="right">&nbsp;</div>
	</div>
   
    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages['CONSIGNEE']}> <{$languages['FIRST_NAME']}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_first_name" value="<{if isset($order.consignee_last_name)}><{$order.consignee_first_name}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;*</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
	<div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages['CONSIGNEE']}> <{$languages['LAST_NAME']}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_last_name" value="<{if isset($order.consignee_first_name)}><{$order.consignee_last_name}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;*</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages['CONSIGNEE']}> <{$languages['COMPANY']}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_company" value="<{if isset($order.consignee_company)}><{$order.consignee_company}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages['CONSIGNEE']}> <{$languages['COUNTRY']}>：</div>
    <div class="middle">
    <select  name="consignee_country_id" class="selectForm" style="width:220px" onchange="getShipping()">
    <option value=""><{$languages['PLS_SELECT']}></option>
    <{foreach item="country" from=$countryList key='key'}>
    <option value="<{$country.country_id}>">
        <{if $languages['LANGUAGEID']=='1'}>
        <{$country.en_name}>
        <{else}>
        <{$country.cn_name}>
        <{/if}>
    </option>
    <{/foreach}>
    </select>
    <span class="red">&nbsp;&nbsp;*</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>

    <input type="hidden" class="inputText" name="warehouse_id" value="1"/>
    <div class="row height28 order_type_row">
		<div class="left"  style="width:23%" ><{$languages.SHIPPING_METHOD}>：</div>
    	<div class="middle">
    		<select  name="shipping_method" class="selectForm" style="width:220px" onchange="getCost()">
        		<option value=""><{$languages.PLS_SELECT}></option>
    		</select><span class="red">&nbsp;&nbsp;&nbsp;*</span>
		</div>
		<div class="right" id="cosInfo">&nbsp;</div>
	</div>

    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages.POSTAL_CODE}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_zip" value="<{if isset($order.consignee_zip)}><{$order.consignee_zip}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
    
    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages.CONSIGNEE}><{$languages.STATE_PROVICE}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_region" value="<{if isset($order.consignee_region)}><{$order.consignee_region}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
    
    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages.CONSIGNEE}><{$languages.CITY}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_city" value="<{if isset($order.consignee_city)}><{$order.consignee_city}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
    
    <div class="row height75 order_type_row">
	<div class="left height75"  style="width:23%"><{$languages.CONSIGNEE}><{$languages.ADDRESS_ONE}>：</div>
    <div class="middle height75">
    <textarea name="consignee_address1" class="inputTextarea"><{if isset($order.consignee_address1)}><{$order.consignee_address1}><{/if}></textarea>
    <span class="red">&nbsp;&nbsp;*</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
   
	<div class="row height75 order_type_row">
	<div class="left height75"  style="width:23%"><{$languages.CONSIGNEE}><{$languages.ADDRESS_TWO}>：</div>
    <div class="middle height75">
    <textarea name="consignee_address2" class="inputTextarea"><{if isset($order.consignee_address2)}><{$order.consignee_address2}><{/if}></textarea>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>

    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages.PHONE}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_phone" value="<{if isset($order.consignee_phone)}><{$order.consignee_phone}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>

    <div class="row height28 order_type_row">
	<div class="left"  style="width:23%"><{$languages.EMAIL}>：</div>
    <div class="middle">
    <input type="text" class="inputText" name="consignee_email" value="<{if isset($order.consignee_email)}><{$order.consignee_email}><{/if}>"/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
<!--
    <div class="row height25">
	<div class="right"  style="width:20%">物品内容描述：</div>
    <div class="middle">
    <input type="text" class="inputText" name="parcel_contents" value=""/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right"></div>
	</div>
    <div class="row height25">
	<div class="right"  style="width:20%">物品申报价值：</div>
    <div class="middle">
    <input type="text" class="inputText" name="parcel_declared_value" value=""/>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right"></div>
	</div>-->
	
    <div class="row height75 ">
	<div class="left height75"  style="width:23%"><{$languages.REMARK}>：</div>
    <div class="middle height75">
    <textarea name="remark" class="inputTextarea"><{if isset($order.remark)}><{$order.remark}><{/if}></textarea>
    <span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
	</div>
    
    <div class="row height28 ">
	<div class="left"  style="width:23%">&nbsp;</div>
    <div class="middle">
	<{if isset($order.order_id)}>
		<input type="hidden" name="order_id" value="<{$order.order_id}>"/>
	<{/if}>
	<span class="button-2" onclick="sumbitOrder()"><{$languages.SUBMIT}></span>
    <input type="hidden" name="shipping_fee_estimate" value=""/>&nbsp;
<span class="red">&nbsp;&nbsp;</span>
    </div>
    <div class="right">&nbsp;</div>
    </div>
</div>
</form>

<div class="prdouctDiv" style="display:none" title="SKUList">
<{include file='merchant/orders/warehouse-products-list.tpl'}>
</div>
<div style="display:none;" class="messageDiv">
    <div id="message"></div>
</div>
<div style="display:none;" class="flushMessageDiv">
    <div id="flushMessage"></div>
</div>

<div id="batchAdd" title="Batch add orders" style="display:none;"> 
	<div class="info">
		<div class="batchAddTips" style="color:red;"></div>		
		<form id="uploadForm" enctype="multipart/form-data" onsubmit="return checkType();" action="/merchant/orders/upload-processing" method="post">
			<div class="item">
				<span class="userInfoLeft">Choose file：</span>
				<span class="userInfoRight">
					<input type="file" name="orderFile" id="orderFile">Support xls, csv file
				</span>
			</div>
		<!--	<input type="submit" name="sumit" value="提交" />-->
		</form>
	
	</div>
</div>

<div id="messageTip" title="Message tip" style="display:none">
	<div style="overflow-y:auto;text-align:center;text-align:left;" id="messageTipOutput"></div>
</div>

<div id="orderInfo" title="Batch add orders" style="display:none"> 
	<{include file='merchant/orders/batchAdd.tpl'}>
</div>